<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@	page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<%@ include file="/taglibs.jsp"%>
<!-- 数字验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<s:url value="/js" var="jsPath"/>
<s:url value="/css" var="cssPath"/>
<s:url value="/images" var="imgPath"/>
<script language="javascript">
$().ready( function() {
	$("#pageNum").numeric();
});

function cancelCoupon(couponItemCode){
	if(confirm("确定要取消?")){
		$.post("${midContextPath}/coupon/jsonCancelCoupon.do",{couponItemCode:couponItemCode},
				cancelResult,"json");
	}
	return null;
}
function cancelResult(result){
	if('OK'==result){
		alert("取消成功");
	}else if('is_used'==result){
		alert("优惠券已被使用");
	}else if('not_reg'==result){
		alert("优惠券未被注册");
	}else{
		alert("优惠码（Coupon Item Code）查无资料");
	}
	doAR('${midContextPath}/coupon/listCouponItem.do?AJAX=true&refreshZone=couponItemList&couponUuid=${couponUuid}&pager.currentPage=${pager.currentPage}','couponItemList');
}
function gotoPage(){
	if(null !=$("#pageNum").val()){
		doAR('${midContextPath}/coupon/listCouponItem.do?AJAX=true&refreshZone=couponItemList&couponUuid=${couponUuid}&pager.currentPage='+($("#pageNum").val()-1),'couponItemList');
	}
}
</script>
<s:if test="couponItems.size > 0">
	<table width="100%">
		<thead class="tb-1">
			<tr>
				<th>卷号</th>
				<th>会员</th>
				<th>订单编号</th>
				<th>激活日期</th>
				<th>使用日期</th>
				<th>适用日期(起)</th>
				<th>适用日期(迄)</th>
				<th>功能</th>
			</tr>
		</thead>
		<tbody class="tb-1">
			<c:forEach items="${couponItems}" var="couponItem" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					<td><a href="${midContextPath}/coupon/queryCouponByCouponItemCode.do?couponItemCode=${couponItem.code}" target="_blank">${couponItem.code}</a></td>
					<td>${couponItem.memberId}</td>
					<td>${couponItem.orderId}</td>
					<td><fmt-rt:formatDate value="${couponItem.regDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td><fmt-rt:formatDate value="${couponItem.useDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td><fmt-rt:formatDate value="${couponItem.startDate}" pattern="yyyy-MM-dd"/></td>
					<td><fmt-rt:formatDate value="${couponItem.endDate}" pattern="yyyy-MM-dd"/></td>
					<td>
					<c-rt:if test="${!empty couponItem.memberId && empty couponItem.orderId}">
					<yaodian100:checkPermission permissions="OTHER_COUPON"><a href="${midContextPath}/coupon/editCouponByCouponItemCode.do?couponItemCode=${couponItem.code}&from=fc">編輯</a>  </yaodian100:checkPermission>
					<yaodian100:checkPermission permissions="OTHER_COUPON,OTHER_CANCELCOUPON"><a href="javascript:;" onclick="cancelCoupon('${couponItem.code}');">取消礼卷</a></yaodian100:checkPermission>
					</c-rt:if></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<yaodian100:pageajaxutil pagerObj="${pager}" link="${midContextPath}/coupon/listCouponItem.do?AJAX=true&refreshZone=couponItemList&couponUuid=${couponUuid}" refreshZone="couponItemList"/>
	<div class="f-link">跳至第<input type="text" size=3 id="pageNum">页<a href="javascript:;" onclick="gotoPage();">确认</a></div>
</s:if>